
function groupModify(obj){
	var type = $(obj).data('type');
	var getDataUrl = '/dlc/'+ type +'/getGroupData';
	$.post(getDataUrl, {}, function(groupData){
		if(groupData.length > 0) {
			var selectHtml = "<div style='text-align:center;padding:20px 20px;'><select class='form-control groupSelect'><option value='0'>请选择分组</option>";
			$.each(groupData, function(k, v){
				selectHtml += "<option value='"+v.id+"'>"+v.name+"</option>";
			})
			selectHtml += "</select></div>";
			layer.open({
				type : 1,
				content : selectHtml,
				area : ['300px', '180px'],
				title : '分组修改',
				btn : ['确定', '取消'],
				move : false
				,yes : function(index){
					var load = layer.load(1);
					$.post('/dlc/'+ type +'/groupChange', {operation_id : $(obj).data('id'), group_id : $('.groupSelect').val()}, function(result){
						layer.close(load);
						if(result.status == 1) {
							layer.closeAll();
							$('#refresh-toggler').click();
							layer.msg(result.msg, {icon : 1});
							//setTimeout(function(){ $('#refresh-toggler').click(); layer.msg(result.msg, {icon : 1}); }, 500);
						} else {
							layer.msg(result.msg, {icon : 2});
						}
					}, 'json');
				}
			});
		} else {
			layer.msg('请先添加分组', {icon : 2});
		}
	})
}

function deviceBind(obj){
	var html = "<div style='text-align:center;padding:20px 20px;'>"+
					"<input class='form-control' id='mobile' type='text' placeholder='请输入需绑定用户手机' />"+
					"<input class='form-control' id='warranty_time' style='margin-top:10px;' type='text' placeholder='请输入保修期'/>"+
				"</div>";
	layer.open({
		type : 1,
		title : '绑定',
		content : html,
		area : ['300px', '220px'],
		btn : ['确定', '取消'],
		move : false
		,yes : function(index){
			var mobile = $('#mobile').val();
			var warranty_time = $('#warranty_time').val();
			var device_id = $(obj).data('id');
			var url = '/dlc/device/bind';
			var load = layer.load(1);
			$.post(url, {mobile : mobile, warranty_time : warranty_time, device_id : device_id, type : 1}, function(result){
				layer.close(load);
				if(result.status == 1) {
					layer.close(index);
					$('#refresh-toggler').click();
					layer.msg(result.msg, {icon : 1});
				} else {
					layer.msg(result.msg, {icon : 2});
				}
			}, 'json')
		}
	});
	
}